package part17_策略模式_鸭子问题.策略加工厂解决ifelse;

import part17_策略模式_鸭子问题.策略加工厂解决ifelse.pojo.LeaveForm;
import part17_策略模式_鸭子问题.策略加工厂解决ifelse.strategy.AuditStrategy;
import part17_策略模式_鸭子问题.策略加工厂解决ifelse.strategy.AuditStrategyFactory;

/**
 * @ClassName: LeaveServiceNew
 * @Author: AllenSun
 * @Date: 2023/2/11 下午10:45
 */
public class LeaveServiceNew {
    public void audit(LeaveForm leaveForm) {
        // 获取一个工厂的单例对象方法getInstance
        AuditStrategyFactory factory = AuditStrategyFactory.getInstance();
        // 根据请假单信息，获取对应的策略类getAuditStrategy
        AuditStrategy auditStrategy = factory.getAuditStrategy(leaveForm);
        System.out.println("符合规则："+auditStrategy.getName()+"("+auditStrategy.getClass().getSimpleName()+")");
        auditStrategy.audit(leaveForm);
    }
}
